<!--选择老师-->
<template>
  <article ref="dialogWrap" class="dialog-wrap" v-if="isShow">
    <div class="head-wrap">
      <div class="header">
        <div @click="back()" class="back"><span class="arrow"></span></div>
        <div class="title">{{headTitle}}</div>
        <div class="btn">
          <div class="inner">
            <slot name="btn"></slot>
          </div>
        </div>
      </div>
    </div>
    <section class="frame-content-sub no-bg">
      <section class="">
        <div class="d-scroll list-wenda" style="">
          <cube-scroll
            ref="scroll"
            :options="options"
            @pulling-up="onPullingUp"
          >
            <div v-for="(item,index) in list" @click="select(item)" class="item block">
              <div class="icon">
                <span class="icon-text">教</span>
              </div>
              <div class="text-wrap">
                <div class="title"><span class="pdr-2">{{item.fullname}}</span>
                </div>
                <div class="tip">
                  <span class="one">邮箱：{{item.email}}</span>
                </div>
                <div class="tip">
                  <span class="one">编号：{{item.userNo}}</span>
                </div>
              </div>
            </div>


            <div class="pdv-3"></div>

          </cube-scroll>
        </div>
        <div class="pdv-3"></div>

      </section>
    </section>
  </article>
</template>

<script>
  import moment from 'moment'
  import _ from 'lodash'
  let currYear = new Date().getFullYear()
  const dateSegmentData = [
    {
      is: 'cube-date-picker',
      title: '开始时间',
      min: new Date(),
      max: new Date(2030, 11, 31)
    },
    {
      is: 'cube-date-picker',
      title: '结束时间',
      min: new Date(),
      max: new Date(2030, 11, 31)
    }
  ]
  export default {
    name: 'selectTeacher',
    data () {
      return {
        options: {
          pullUpLoad: true,
          scrollbar: false
        },
        headTitle: '选择用户',
        isShow: !false,
        list: [],
        pageIndex: 1,
        pageSize: 10
      }
    },
    mounted () {
      this.usersQueryList()
    },
    methods: {
      select (item) {
        this.$emit('onSelect', item)
        this.back()
      },
      show () {
        this.isShow = true
      },
      back () {
        this.isShow = false
      },
      // 获取教师
      usersQueryList () {
        let params = {
          page: this.pageIndex,
          limit: this.pageSize,
          dimId: 4,
          allChildren: 0
        }
        return this.fetchService.usersQueryList(params).then(res => {
          if (res.code !== 0) {
            return this.tools.tip(res.message || '接口服务出错，请联系管理员')
          }
          this.list = this.list.concat(res.data)
          return res
        })
      },
      onPullingUp () {
        this.pageIndex ++
        this.usersQueryList().then(res => {
          setTimeout(() => {
            this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate(true, false)
            this.options.isPullUpLoad = !true
          }, 100)
        })
      }
    }
  }
</script>

<style scoped>

</style>
